//
//  TableHeaderView.m
//  PropertyMananger
//
//  Created by Mansion on 16/12/24.
//  Copyright © 2016年 BH. All rights reserved.
//

#import "TableHeaderView.h"

@implementation TableHeaderView

extern UserInfoModel const * userModel;

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.bgView = [[UIView alloc]init];
        [self addSubview:self.bgView];
  
        [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self).with.offset(0);
            make.leading.equalTo(self).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(BHscreenW, 200));
        }];
        
        self.headerBgView = [[UIImageView alloc]init];
        [self.bgView addSubview:self.headerBgView];
        self.headerBgView.image = [UIImage imageNamed:@"bg_my"];

        [self.headerBgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self).with.offset(0);
            make.leading.equalTo(self).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(BHscreenW, 200));
        }];
        
        //头像
        self.headerImg = [[UIImageView alloc]init];
        [self.bgView addSubview:self.headerImg];
        self.headerImg.image = [UIImage imageNamed:@"ico_user_head"];
//        self.headerImg.layer.cornerRadius = 10;
//        self.headerImg.layer.masksToBounds = YES;
        
        [self.headerImg mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self).with.offset(0);
            make.centerY.equalTo(self).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(70,70));
        }];
        //name
        self.nameLabel = [[UILabel alloc]init];
        [self addSubview:self.nameLabel];
     //  self.nameLabel.text = @"白开水";
        self.nameLabel.text = userModel.RealName;

        self.nameLabel.textColor = [UIColor whiteColor];
        self.nameLabel.textAlignment = NSTextAlignmentCenter;
        self.nameLabel.font = BHFont(16);
        
        [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self).with.offset(0);
            make.top.equalTo(self.headerImg.mas_bottom).with.offset(5);
            make.size.mas_equalTo(CGSizeMake(BHscreenW/2, 30));
        }];
        
        //subtitle
        self.subTitle = [[UILabel alloc]init];
        [self.bgView addSubview:self.subTitle];
        self.subTitle.text = @"账号:123小明";
        self.subTitle.text = [NSString stringWithFormat:@"账号:%@",userModel.Tel];
        self.subTitle.textColor = [UIColor whiteColor];
        self.subTitle.textAlignment = NSTextAlignmentCenter;
        self.subTitle.font = BHFont(13);
        
        [self.subTitle mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self).with.offset(0);
            make.top.equalTo(self.nameLabel.mas_bottom).with.offset(-10);
            make.size.mas_equalTo(CGSizeMake(BHscreenW/2, 30));
        }];
        
        self.exsitBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [self.bgView addSubview:self.exsitBtn];
        
        [self.exsitBtn setTitle:@"退出" forState:UIControlStateNormal];
        [self.exsitBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        self.exsitBtn.titleLabel.font = BHFont(13);
        self.exsitBtn.titleLabel.textAlignment = NSTextAlignmentRight;
        
     //   [self.exsitBtn addTarget:self action:@selector(exsitBtnClick:) forControlEvents:UIControlEventTouchUpInside];
        
        [self.exsitBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.trailing.equalTo(self).with.offset(-15);
            make.top.equalTo(self).with.offset(35);
            make.size.mas_equalTo(CGSizeMake(30, 30));
        }];

    }
    return self;
}

- (void)exsitBtnClick:(UIButton *)btn
{
    DLog(@"退出");
   
    
}
@end
